package com.lanchetech.merchant.controller;

import com.lanchetech.bean.request.ActivityBindSpuReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.response.SpuResp;
import com.lanchetech.entity.ActivityBindSpu;
import com.lanchetech.merchant.service.ActivityBindSpuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(value = "绑定商品接口", tags = "绑定商品接口")
@RequestMapping("/api/activityBindSpu")
@RestController
public class ActivityBindSpuController {

    @Resource
    private ActivityBindSpuService bindSpuService;


    @ApiOperation("添加或编辑绑定活动商品信息")
    @PostMapping("/editActivitySpu")
    public BaseResp bindSpu(@RequestBody ActivityBindSpu bindSpu){
        return bindSpuService.bindSpu(bindSpu);
    }


    @ApiOperation("绑定或解绑活动商品信息")
    @GetMapping("/unBindSpu")
    public BaseResp unBindSpu(@RequestParam("id") Long id){
        return bindSpuService.unBindSpu(id);
    }


    @ApiOperation("查看绑定活动商品分页列表")
    @PostMapping("/getPage")
    public ResultData<BasePageResp<SpuResp>> getPage(@RequestBody ActivityBindSpuReq req){
        return bindSpuService.getBindPage(req);
    }
}
